using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Terminal.Advanced_AEUC_settings_controls.Settings_AUX;
using Terminal.Advanced_AEUC_settings_controls.Settings_Interfaces;
using Terminal.Advanced_AEUC_settings_controls.Setting_Advanced_Control;

namespace Terminal.Advanced_AEUC_settings_controls.Settings_Editing_Forms
{
    /// <summary>
    /// General form for editting aeuc buttons mapping to aeuc messages
    /// </summary>
    public partial class AEUCButtonEditForm : Form
    {
        AEUCSettingButton btnSetting;
        /// <summary>
        /// Constructor of the form
        /// </summary>
        /// <param name="ibtnSetting">AEUC button that will be edited</param>
        public AEUCButtonEditForm(AEUCSettingButton ibtnSetting)
        {
            InitializeComponent();
            btnSetting = ibtnSetting;
        }

        private void AEUCButtonEditForm_Load(object sender, EventArgs e)
        {
            for (int i = 0; i<btnSetting.GetAssociatedParent.cmcDefinitios.AEUC_MSG.Count; i++)
            {
                cbMessages.Items.Add(btnSetting.GetAssociatedParent.cmcDefinitios.AEUC_MSG[i]);
            }
            for (int i = 0; i<btnSetting.GetAssociatedParent.cmcDefinitios.SPECMSG_MSG.Count; i++)
            {
                cbMessages.Items.Add(btnSetting.GetAssociatedParent.cmcDefinitios.SPECMSG_MSG[i]);
            }
            if (cbMessages.Items.Count > 0)
                cbMessages.SelectedIndex = 0;
            tbButtonName.Text = btnSetting.SetButtonName;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void btnApply_Click(object sender, EventArgs e)
        {
            if (cbMessages.SelectedIndex > -1)
                btnSetting.SetAssociatedMessage = (GenMSG)cbMessages.SelectedItem;
            btnSetting.SetButtonName = tbButtonName.Text;
            Close();
        }
    }
}